package com.yang.srb.sms.service.impl;

import com.yang.common.util.RandomUtils;
import com.yang.srb.sms.service.SmsService;
import lombok.extern.slf4j.Slf4j;
import org.checkerframework.checker.units.qual.A;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.LinkedList;
import java.util.Objects;
import java.util.concurrent.TimeUnit;

@Slf4j
@Service
public class SmsServiceImpl implements SmsService {
    @Resource
    private RedisTemplate redisTemplate;

    @Override
    public void send(String mobile)  {

            String fourBitRandom = RandomUtils.getFourBitRandom();
            redisTemplate.opsForValue().set("srb:sms:code:" + mobile,fourBitRandom,60, TimeUnit.SECONDS);
//            RequestModel model = new RequestModel();
//            model.setGwUrl(SmsProperties.GW_Url);
//            model.setAppkey(SmsProperties.APP_KEY);
//            Map queryMap = new HashMap();
//            queryMap.put("mobile",mobile); //访问参数
//            queryMap.put("content","【创信】你的验证码是："+fourBitRandom+"，3分钟内有效！"); //访问参数
//            model.setQueryParams(queryMap);
//            WxApiCall call = new WxApiCall();
//            call.setModel(model);
//            String request = call.request();
//            Map map = JSON.parseObject(request, Map.class);
//            String code = (String) map.get("code");
//            String msg = (String) map.get("msg");
//            Assert.notEquals("10010",code,ResponseEnum.ALIYUN_SMS_ERROR_10010);
//            Assert.equals("10000", code, ResponseEnum.ALIYUN_SMS_ERROR);

    }
}
